package text2;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class server {
    public static void main(String[] args) throws IOException {
        //接收数据
        ServerSocket ss = new ServerSocket(10003);
        //获取输入流
        Socket socket = ss.accept();
        InputStream is = socket.getInputStream();
        int b;
        while ((b=is.read())!=-1)
        {
            System.out.print((char)b);
        }


        //然后再将数据写回发送端
        //获取输出流
        OutputStream os = socket.getOutputStream();
        os.write("metoo".getBytes());
        socket.close();
        ss.close();


    }
}
